const Mock = require('mockjs')

const Random = Mock.Random
const getQuestionList = require('./data/getQuestionList')
module.exports = [
    {
        url:'/api/question/:id',
        method:'get',
        response() {
            return {
                errno:0,
                data:{
                    id:Random.id(),
                    name:Random.cname(),
                    title:Random.ctitle()
                }
            }
        }
    },
    // 创建问卷
    {
        url:'/api/question',
        method:'post',
        response() {
            return {
                errno:0,
                data:{
                    id:Random.id()
                }
            }
        }
    },
// 获取(查询)问卷列表
{
    url:'/api/question',
    method:'get',
    response(ctx) {
        const { url = '',query = {} } = ctx
        console.log('ctx url',url)
        console.log('ctx query',query)
        const isDeleted = url.includes('isDeleted=true')
        const isStar = url.includes('isStar=true')
        const page = query.page
        const pageSize = query.pageSize
        return {
            errno:0,
            data:{
                list:getQuestionList({len:pageSize,isDeleted,isStar}),
                total:100 // 总页数  分页
            }
        }
    }
}
]